<template>
<div class="tree scroll">
    <div class="tree-header">贵阳市消防支队</div>
    <div class="tree-extra">
        <input type="date" class="datepicker" @change.native="requestEffEvaluate" v-model="startTime" />
    </div>

    <ul class="tree-body">
        <li v-for="(item,index) in deplist" :key="'dl-'+ index">
            <div class="tree-node" @click="requestEffEvaluate(item)" :class="{actived:depActiveCheck(item)}">{{item}}</div>
        </li>
    </ul>
</div>
</template>

<script>
import bus from "@/utils/bus";
import axios from "axios";
export default {
    name: "",
    data() {
        return {
            deplist: [],
            depName: null,
            startTime: null
        };
    },
    created() {
        axios.get(this.URLHEAD_DVS + "GetFireUserGroupList").then(res => {
            let json = res.data;
            this.deplist = json.Data;
        });
        bus.$on('eff-select-dep',msg=>{
          this.startTime = msg.startTime
          this.depName = msg.depName
        })
    },
    methods: {
        requestEffEvaluate(depname) {
            this.depName = depname ? depname : this.depName;
            let msg = {
                depName: this.depName,
                startTime: this.startTime
            };
            bus.$emit("eff-select-dep", msg);
        },
        depActiveCheck(depname){
          if(this.depName === depname){
            return true
          }else{
            return false
          }
        }
    }
};
</script>

<style lang="" scoped>
.datepicker {
    border: 1px #7ecdf560 solid;
    color: #7ecdf5;
    margin-left: 20px;
    padding: 3px 10px;
}
</style>
